#include <bits/stdc++.h>
using namespace std;
int s[10000];
int main() {
  int a, b, m, n;
  cin >> a >> b >> m >> n;
  if (a >= m) {
    cout << a;
    return 0;
  }
  if (b >= m) {
    cout << a + b;
    return 0;
  }
  s[1] = a;
  s[2] = b;
  for (int i = 3; i <= n; i++) {
    s[i] = s[i - 1] + s[i - 2];
    if (s[i] >= m)
      break;
  }
  int box = 0;
  for (int i = 1; i <= n; i++) {
    box += s[i];
  }
  cout << box;
  return 0;

}